package dowork;

import android.graphics.Point;
import com.android.uiautomator.core.UiDevice;
import com.android.uiautomator.testrunner.UiAutomatorTestCase;
import java.util.Random;

public class SwipTest extends UiAutomatorTestCase {
    private static final int cosShape = 2;
    private static final int miShape1 = 16;
    private static final int miShape2 = 32;
    private static final int ovalShape1 = 4;
    private static final int ovalShape2 = 8;
    private static final int sShape1 = 64;
    private static final int sinShape = 1;
    private static final int yuanShape = 128;

    private static Point[] getArcPoints(int i, int i2, int i3, int i4) {
        Random random = new Random();
        Point[] pointArr = new Point[i];
        int nextInt = random.nextInt((i2 * 3) / ovalShape1) + (i2 / ovalShape2);
        int nextInt2 = random.nextInt(i3 / 6) + (i3 / ovalShape2);
        pointArr[0] = new Point(nextInt, nextInt2);
        int nextInt3 = (i2 / ovalShape2) + random.nextInt((i2 * 3) / ovalShape1);
        int nextInt4 = (random.nextInt(i2 / ovalShape1) + nextInt2) + (i3 / 3);
        int i5 = nextInt3 - nextInt;
        int i6 = nextInt4 - nextInt2;
        Object obj = sinShape;
        if (i5 < 0) {
            i5 = nextInt - nextInt3;
            obj = -1;
        }
        if (i5 < i2 / ovalShape1) {
            i5 = i2 / 3;
            if (nextInt > i2 / 2) {
                nextInt3 = nextInt - (i2 / 3);
                obj = -1;
            } else {
                nextInt3 = nextInt + (i2 / 3);
                obj = sinShape;
            }
        }
        int i7 = sinShape;
        while (i7 < i) {
            int i8 = (i7 * i5) / (i - 1);
            int i9 = nextInt + i8;
            int i10 = ((i7 * i6) / (i - 1)) + nextInt2;
            if (obj < null) {
                i9 = nextInt - ((i7 * i5) / (i - 1));
            }
            if (i5 < i2 / 3) {
                i10 = nextInt4 - ((int) (((double) (nextInt4 - nextInt2)) * Math.cos((3.141592653589793d * ((double) ((i7 * i5) / (i - 1)))) / ((double) (i5 * 2)))));
            } else if (i4 == sinShape) {
                i10 = ((int) (((double) (nextInt4 - nextInt2)) * Math.sin((3.141592653589793d * ((double) ((i7 * i5) / (i - 1)))) / ((double) (i5 * 2))))) + nextInt2;
            } else if (i4 == 2) {
                i10 = nextInt4 - ((int) (((double) (nextInt4 - nextInt2)) * Math.cos((3.141592653589793d * ((double) ((i7 * i5) / (i - 1)))) / ((double) (i5 * 2)))));
            } else if (i4 == ovalShape1) {
                i10 = nextInt4 - ((int) (Math.sqrt(1.0d - (((double) (i8 * i8)) / ((double) (i5 * i5)))) * ((double) i6)));
            } else if (i4 == ovalShape2) {
                i10 = ((int) (Math.sqrt(1.0d - (((double) ((i5 - i8) * (i5 - i8))) / ((double) (i5 * i5)))) * ((double) i6))) + nextInt2;
            } else if (i4 == sShape1) {
                i10 = i / 2;
                i8 = ((i * i6) / ((i - 1) * 2)) + nextInt2;
                i10 = i7 < i10 ? ((int) (((double) (i8 - nextInt2)) * Math.sin((3.141592653589793d * ((double) ((i7 * i5) / i10))) / ((double) (i5 * 2))))) + nextInt2 : nextInt4 - ((int) (((double) (nextInt4 - i8)) * Math.cos((3.141592653589793d * ((double) (((i7 - i10) * i5) / ((i - 1) - i10)))) / ((double) (i5 * 2)))));
            } else if (i4 == miShape1) {
                i10 = nextInt4 - (i6 - (((i6 * i8) * i8) / (i5 * i5)));
            } else if (i4 == miShape2) {
                i10 = (i6 - ((((i5 - i8) * i6) * (i5 - i8)) / (i5 * i5))) + nextInt2;
            } else if (i4 == yuanShape) {
                i9 = ((nextInt3 + nextInt) - ((i6 * i6) / (nextInt - nextInt3))) / 2;
                i9 = nextInt > nextInt3 ? i9 + ((int) Math.sqrt((double) (((i9 - nextInt) * (i9 - nextInt)) - ((nextInt2 - i10) * (nextInt2 - i10))))) : i9 - ((int) Math.sqrt((double) (((i9 - nextInt) * (i9 - nextInt)) - ((nextInt2 - i10) * (nextInt2 - i10)))));
            }
            pointArr[i7] = new Point(i9, i10);
            i7 += sinShape;
        }
        return pointArr;
    }

    public void testDoWork() {
        UiDevice uiDevice = getUiDevice();
        int displayWidth = uiDevice.getDisplayWidth();
        int displayHeight = uiDevice.getDisplayHeight();
        Random random = new Random();
        int nextInt = random.nextInt(ovalShape1) + 7;
        int pow = (int) Math.pow(2.0d, (double) ((random.nextInt(100) + sinShape) % 7));
        if (pow == ovalShape2) {
            nextInt--;
        }
        System.out.println("shape type:" + pow);
        Point[] pointArr = new Point[nextInt];
        uiDevice.swipe(getArcPoints(nextInt, displayWidth, displayHeight, pow), 3);
    }
}
